package com.woniuxy.stage3demo.service.hpxservice.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.stage3demo.bean.hpxbean.ContractBean;
import com.woniuxy.stage3demo.bean.hpxbean.OrderBean;
import com.woniuxy.stage3demo.mapper.hpxmapper.ContractMapper;
import com.woniuxy.stage3demo.pageHelper.PageRequest;
import com.woniuxy.stage3demo.service.hpxservice.IContractService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;


@Service
@Transactional(readOnly = true)
public class ContractServiceImpl implements IContractService {

    @Resource
    private ContractMapper contractMapper;

    //分页查询
    @Override
    public PageInfo<ContractBean> findAllByParams(PageRequest request, ContractBean contractBean) {
        return PageHelper.startPage(request.getPageNum(),request.getLimit()).
                doSelectPageInfo(()->contractMapper.findAllByParams(request,contractBean));
    }

    //查询今天
    @Override
    public int todayContract() {
        return contractMapper.todayContract();
    }

    //查询7天
    @Override
    public int weekContracts() {
        return contractMapper.weekContracts();
    }

    //查询一月
    @Override
    public int monthContracts() {
        return contractMapper.monthContracts();
    }

    //查询总数
    @Override
    public int totalContracts() {
        return contractMapper.todayContract();
    }

    @Override
    public ContractBean checkOne(ContractBean contractBean) {
        return contractMapper.checkOne(contractBean);
    }
}
